package com.muki.spider.core.filter;

import java.util.ArrayList;
import java.util.List;

import com.muki.spider.core.FilterChain;
import com.muki.spider.core.FlagUri;
import com.muki.spider.core.RequestUri;
import com.muki.spider.core.UriFilter;

public class MukiFootFilter implements UriFilter{

	private String defualt_uncheck="css|js|exe|zip|rar|gzip|pdf|doc|docx|xls|xlsx";
	private List<String> uncheck = new ArrayList<>();
	
	public MukiFootFilter() {
		String[] array = defualt_uncheck.split("\\|");
		for(String str:array) {
			uncheck.add(str);
		}
	}
	
	@Override
	public void filter(RequestUri request, FilterChain chain) {
		FlagUri uri = request.getFlagUri();
		for(String check:uncheck) {
			if(uri.getUri().endsWith(check)) {
				return ;
			}
		}
		chain.doFilter(request);
		
	}

	@Override
	public void destroy() {
		
	}

	@Override
	public void init() {
		
	}

}
